package Operation;//操作包

import mybook.MyBook;
import mybook.MyBookList;

import java.util.Scanner;

//新增图书类
    public class Add implements IOperation{


    @Override
    public void work(MyBookList myBookList) {
        System.out.println("请输入新增的图书：");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入书名：");
        String title = scanner.nextLine();
        System.out.println("请输入作者：");
        String author = scanner.nextLine();
        System.out.println("请输入所属类型：");
        String type = scanner.nextLine();
        String d = scanner.nextLine();
        System.out.println("请输入价格：");
        double price = scanner.nextDouble();


        MyBook book = new MyBook(title,author,type,price);

        int currentCount = myBookList.getCount();

        myBookList.setBook(currentCount,book);
        System.out.println("图书新增成功");
        myBookList.setCount(currentCount + 1);
    }

}